package com.oriental.manage.service.specially;

import com.oriental.manage.core.exception.BusiException;
import com.oriental.manage.core.paging.Pagination;
import com.oriental.manage.service.reserve.ReserveUtil;
import com.oriental.riskfront.api.model.specially.ResponseModel;
import com.oriental.riskfront.api.model.specially.TBlackListDto;
import com.oriental.riskfront.api.service.TBlackListInterface;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class BlackListService {

    @Autowired
    private TBlackListInterface tBlackListInterface;

    /**
     * 查询黑名单、风险提示信息
     * @return
     */

    public void queryTBlackList(Pagination<TBlackListDto> pagination, TBlackListDto tBlackListDto, ResponseModel<Pagination<TBlackListDto>> responseDTO){
        ResponseModel<List<TBlackListDto>> responseModel = tBlackListInterface.queryTBlackList(tBlackListDto);
        //ReserveUtil.responseQueryHandle(responseModel, pagination, responseDTO, tBlackListDto, "查询失败");
        if (null != responseModel && responseModel.isSuccess()) {
            pagination.setList(responseModel.getResult());
            pagination.setRowCount(0);
            if (responseModel.getResult().size() > 0) {
                pagination.setRowCount(responseModel.getResult().get(0).getRowCount());
                pagination.setPageNum(tBlackListDto.getPageNum());
                pagination.setPageSize(tBlackListDto.getPageSize());
            }
            responseDTO.setResult(pagination);
            responseDTO.setSuccess(true);
        } else if (null != responseModel) {
            responseDTO.setErrorCode(responseModel.getErrorCode());
            responseDTO.setErrorMsg(responseModel.getErrorMsg());
        } else {
            throw new BusiException("查询失败");
        }
    }

}
